/**
 * Collection lists
 * -- backoffice_adminusers
 */

var Schema = mongoose.Schema;

//===========================backoffice_adminusers==============================
var adminUsersSchema = new Schema({
    loginId:{type: String, unique: true, required: true}, //管理员用户名，唯一
    userName: String, //管理员用户名，唯一
    password: {type: String, required: true},  //管理员密码，唯一
    role:{type:String,enum: ['Admin', 'Operation', 'Guest','Service']},
    appuser:{type: Schema.Types.ObjectId, ref: 'user'},
    communities:[{type: Schema.Types.ObjectId, ref: 'community'}],
    signed:{type: Boolean, default: false},
    dateCreated: {type: Date, default: Date.now}, //创建日期
    dateLastModified: {type: Date, default: Date.now} //最后修改日期
});
mongoose.model('backoffice_adminusers', adminUsersSchema,'backoffice_adminusers');

var backofficeUserBehavior = new Schema({
    ip:String,
    userId:{type: Schema.Types.ObjectId, ref: 'backoffice_adminusers'},
    reqUrl:String,
    input:String,
    datetime:{type:Date,default:Date.now}
});
mongoose.model('backoffice_user_behavior', backofficeUserBehavior,'backoffice_user_behavior');